<?php

use Illuminate\Http\Request;

Route::get('/', 'IndexController@index');
Route::get('product/list/{id}', 'ListController@index')->name('list');
Route::get('product/search', 'ContentController@search');
Route::get('product/content/{id}', 'ContentController@index')->name('content');
Route::get('download/{file}', 'DownloadController@index')->name('download');
Route::get('admin/login', 'Admin\LoginController@index');
Route::post('admin/doLogin', 'Admin\LoginController@doLogin');
Route::post('getChildren', 'CommonController@getChildren');
Route::post('getProduct', 'CommonController@getProduct');
//Route::get('test', 'TestController@index');

//后台路由
Route::group(['prefix' => 'admin', 'middleware' => 'isLogin', 'namespace' => 'Admin'], function () {

    Route::get('/', 'IndexController@index');
    Route::get('logout', 'IndexController@logout');

    //产品管理
    Route::get('product', 'ProductController@index');
    Route::any('product/add', 'ProductController@add');
    Route::post('product/del', 'ProductController@del');
    Route::any('product/edit/{id}', 'ProductController@edit')->name('productEdit');

    //分类管理
    Route::get('type', 'TypeController@index');
    Route::any('type/factory', 'TypeController@factory');
    Route::any('type/model', 'TypeController@model');
    Route::any('type/product', 'TypeController@product');
    Route::post('type/del', 'TypeController@del');
    Route::post('type/getModel', 'TypeController@getModel');
    Route::any('type/edit/{id}', 'TypeController@edit')->name('typeEdit');

    //栏目管理
    Route::get('category', 'CategoryController@index');
    Route::any('category/add', 'CategoryController@add');
    Route::post('category/del', 'CategoryController@del');
    Route::post('category/dels', 'CategoryController@dels');
    Route::any('category/edit/{id}', 'CategoryController@edit')->name('categoryEdit');

    //内容管理
    Route::get('article', 'ArticleController@index');
    Route::any('article/add', 'ArticleController@add');
    Route::post('article/del', 'ArticleController@del');
    Route::any('article/edit/{id}', 'ArticleController@edit')->name('articleEdit');

    //管理员管理
    Route::get('member', 'MemberController@index');
    Route::any('member/add', 'MemberController@add');
    Route::post('member/del', 'MemberController@del');
    Route::any('member/edit/{id}', 'MemberController@edit')->name('memberEdit');
});
